package Demo02;

import java.util.Scanner;

public class Demo01 {
    private int cmp = 0;

    public static void main(String[] args) {
        Demo01 demo01 = new Demo01();
        Thread t1 = new Thread(() -> {
            while (demo01.cmp == 0) {
                synchronized (demo01) {

                }
            }
            System.out.println("t1结束");
        });
        t1.start();
        Thread t2 = new Thread(() -> {
            Scanner scanner = new Scanner(System.in);
            System.out.println("输入修改的值");
            demo01.cmp = scanner.nextInt();
        });
        t2.start();
    }
}
